<!--
var unreserved = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_.~/:";
var reserved = "!*'();@&=+$,?%#[]";
var allowed = unreserved + reserved;
var hexchars = "0123456789ABCDEFabcdef";
function gethex(decimal) 
{
  return "%+ space" + hexchars.charAt(decimal >> 4) + hexchars.charAt(decimal & 0xF);
}
// Encode function
function encode() 
{
  document.conv.cutecode.value = "";
  var url = document.conv.url.value;
  var urlb = document.conv.urlb.value;
  var ma = document.conv.ma.value;
  var mb = document.conv.mb.value;
  var mc = document.conv.mc.value;
  var md = document.conv.md.value;
  var id = document.conv.id.value;
  var h = document.conv.h.value;
  var s = document.conv.s.value;
  var f = document.conv.f.value;
  var c = document.conv.c.value;
  var r = document.conv.r.value;
  var cutecode = "";
  var pstn = document.conv.pstn.value;
  var jsc = 'tw-corner';
  var jsb = 'tw-sb';
    if (pstn == 'tl') {
        var pst = 'Top-Left';
		var p = jsc;
    } else if (pstn == 'tr') {
        var pst = 'Top-Right';
		var p = jsc;
    } else if (pstn == 'bl') {
        var pst = 'Bottom-Left';
		var p = jsc;
    } else if (pstn == 'br') {
        var pst = 'Bottom-Right';
		var p = jsc;
    } else if (pstn == 'sb') {
        var pst = 'Sidebar';
		var p = jsb;
    }	else {
        var pst = 'Nom';
    }
  var notascii = "";
	for (var i = 0; i < url.length; i++ ) {
      var ch = url.charAt(i);
      if (unreserved.indexOf(ch) != -1) {
        cutecode = cutecode + ch;
      } else {
        var charcode = url.charCodeAt(i);
        if (charcode < 128) {
          cutecode = cutecode + gethex(charcode);
        } else {
          cutecode = cutecode + ch;
          notascii = notascii + ch + " ";
        } }}
		
document.getElementById('prev').innerHTML = "<object classid=\"clsid:d27cdb6e-ae6d-11cf-96b8-444553540000\" width=\"150\" height=\"300\" id=\""+id+"\" align=\"middle\"><param name=\"movie\" value=\"https://sites.google.com/site/talkingwidget/tw1a.swf\" /><param name=\"quality\" value=\"high\" /><param name=\"wmode\" value=\"transparent\" /><param name=\"FlashVars\" value=\"i="+url+"&b=https://sites.google.com/site/talkingwidget/"+urlb+".swf&ma="+ma+"&mb="+mb+"&mc="+mc+"&md="+md+"&h="+h+"&f="+f+"&s="+s+"\"><!--[if !IE]>--><object type=\"application/x-shockwave-flash\" data=\"https://sites.google.com/site/talkingwidget/tw1a.swf\" width=\"150\" height=\"300\"><param name=\"movie\" value=\"https://sites.google.com/site/talkingwidget/tw1a.swf\" /><param name=\"quality\" value=\"high\" /><param name=\"wmode\" value=\"transparent\" /><param name=\"FlashVars\" value=\"i="+url+"&b=https://sites.google.com/site/talkingwidget/"+urlb+".swf&ma="+ma+"&mb="+mb+"&mc="+mc+"&md="+md+"&h="+h+"&f="+f+"&s="+s+"\"><!--<![endif]--><!--[if !IE]>--></object><!--<![endif]--></object>";
document.conv.cutecode.value = "<!-- Start TalkingWidgets-"+pst+" -->\n<script language=\"JavaScript\" src=\"http://cuteblog.googlecode.com/svn/trunk/"+p+".js\" type=\"text/javascript\"></script><script language=\"JavaScript\" type=\"text/javascript\">tw(\""+urlb+"\",\""+url+"\",\""+id+urlb+pstn+"\",\""+c+"\",\""+ma+"\",\""+mb+"\",\""+mc+"\",\""+md+"\",\""+h+"\",\""+f+"\",\""+s+"\",\""+r+"\",\""+pstn+ "\")</script>\n<!-- End TalkingWidgets-"+pst+" -->" ;
    if (notascii != "") alert("Warning: Non-ASCII characters in text!\n\nThus, these characters have not been encoded:\n" + notascii);
}
